package main

import "sync"

type MyChannel struct {
	C      chan int
	closed bool
	mutex  sync.Mutex
}

func NewChannel() *MyChannel {
	return &MyChannel{
		C: make(chan int),
	}
}

func (mc *MyChannel) SafeClose() {
	mc.mutex.Lock()
	defer mc.mutex.Unlock()
	if !mc.closed { // 如果此通道没有关闭
		close(mc.C)
		mc.closed = true

	}
}

func (mc *MyChannel) IsClosed() bool {
	mc.mutex.Lock()
	defer mc.mutex.Unlock()
	return mc.closed
}
func main() {

}
